package netty.test5ZeroCopy;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class OldClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost", 7002);
        String fileName="d:/a.txt";
        InputStream in=new FileInputStream(fileName);
        DataOutputStream dataOut=new DataOutputStream(socket.getOutputStream());
        byte [] buffer=new byte[4096];
        long readCount;
        long total=0;
        long startTime=System.currentTimeMillis();
        while((readCount=in.read(buffer))>=0){
            total+=readCount;
            dataOut.write(buffer);
            System.out.println("发送的总字节数  "+total+",耗时 "+(System.currentTimeMillis()-startTime));
            dataOut.close();
            socket.close();
            in.close();
        }
    }
}
